{php include wl_template('common/header');}
{if $config['base']['meiqia']>0}
<script type='text/javascript'>
    (function(m, ei, q, i, a, j, s) {
        m[a] = m[a] || function() {
            (m[a].a = m[a].a || []).push(arguments)
        };
        j = ei.createElement(q),
            s = ei.getElementsByTagName(q)[0];
        j.async = true;
        j.charset = 'UTF-8';
        j.src = i + '?v=' + new Date().getUTCDate();
        s.parentNode.insertBefore(j, s);
    })(window, document, 'script', '//static.meiqia.com/dist/meiqia.js', '_MEIQIA');
    _MEIQIA('entId', {$config['base']['meiqia']});
	</script>
	{/if}
<style>
		.link-rule{
		height:100%;
		width:100%;
		background-color:
		rgba(128,128,128,0.5);
		position:fixed;top:0px;
		left:0px;
		z-index:10000;
	}
	.link-rule>div{
		text-align:center;
		position:absolute;
		top:0;
		bottom:0;
		left:8px;
		right:8px;
		margin-top:auto;
		margin-bottom:auto;
		height:85%;
		background-color:white;
		border-radius:8px;
	}
	.link-rule>div>div:first-child{
		 font-weight:bold;
		 background-color:#ececec;
		 font-size:20px;
		 line-height:40px;
		 border-radius:8px 8px 0 0;
		 height:40px;
	}
	.link-rule>div div:nth-child(2){
		 text-align:left;
		 position:absolute;
		 top:48px;
		 bottom:45px;
		 left:19px;
		 right:19px;
		 overflow:scroll;
	}
	.link-rule>div div:last-child{
		 position:absolute;
		 left:0px;
		 right:0px;
		 width:150px;
		 height:30px;
		 bottom:5px;
		 background-color:{$_W['system_color']};
		 color:white;
		 font-size:18px;
		 margin-left:auto;
		 margin-right:auto;
		 line-height:30px;
		 border-radius:5px;
	}
	#pricedown {   
		display: block;
		width: 40px;
		height: 40px;
		background-color: hsl(194, 57%, 64%);
		color: hsl(0, 0%, 100%);
		line-height: 15px;
		text-align: center;
		border-radius: 20px;
		padding-top: 5px;
		font-size: 12px;
		right: 20px;
		bottom: -20px;
		position: absolute;
	}
	#popJieT {z-index:10086;position:fixed;left:20%;bottom:50px;width:40%;min-height:50px;height:auto;background-color:hsl(354, 91%, 73%);text-align:center;color:white;line-height:25px;}
	#popJieT .jieStep {width:100%;height:50px;border-bottom:1px solid #444;}
	#numJieT, #priceJieT {display:none;}
	#goodsid,#numPerson,#numPrices,#numGroup, #tuanPre {display:none;}
	#jieTiGroup {background-color:white;padding:10px;}
	#jieTiGroup>div:first-child>div:first-child{width:100%;height:20px;}
	#jieTiGroup>div:first-child>div:first-child>div:first-child{height:20px;width:50%;line-height:20px;box-sizing:border-box;float:left;}
	#jieTiGroup>div:first-child>div:first-child>div:last-child{height:20px;width:100%;line-height:20px;box-sizing:border-box;text-align:right;}
	#jieTiGroup>div:first-child>div:nth-child(2){margin-top:20px;margin-bottom:20px;position:relative;width:90%;margin-left:5%;height:20px;border-radius:10px;background-color:white;border:1px solid hsl(354, 91%, 73%)}
	#progressBar {background-image:linear-gradient(90deg,#6fbfd8,hsl(354, 91%, 73%));height:100%;border-radius:10px;left:0px;top:0px;}
	.progressStep {border:1px solid white;height:14px;width:4px;border-radius:7px;position:absolute;top:2px;background-color:white;}
	.progressStep>div:first-child {position: absolute;top: -20px;width: 40px;text-align: center;left: -20px;line-height: 20px;height: 20px;}
	.progressStep>div:last-child {position: absolute;top: 14px;width: 40px;text-align: center;left: -20px;line-height: 20px;height: 20px;}
	#payToGroup {height: 30px;line-height: 30px;text-align: center;width: 80%;background-color: rgb(248, 123, 136);border-radius: 20px;color: white;margin-left: 10%;}
	#over {text-align:right}
	.progress>.progressStep:first-child {background-color:transparent!important;border:none!important;}
	.link-rule p {text-indent:2em;}
		.stepGuild .step_tit i,.stepGuild .step_item_on .step_num{
			background-color:{$_W['system_color']} ;
		}
		.pinTuanJia{
			padding:10px;
			margin-top:-10px;
			background: #fff;
		}
		.pinTuanJia>div:first-child{
			float: left;
			background: {$_W['system_color']};
			font-size: 18px;
			color: #fff;
			width: 60px;
			height: 30px;
			line-height: 30px;
			border-top-left-radius: 5px;
			border-bottom-left-radius: 5px;
			text-align: center;
		}
		.pinTuanJia>div:last-child{
			display:inline-block;
		}
		.pinTuanJia ul{
			border: 1px solid #ddd;
			border-bottom:none;
		}
		.pinTuanJia li{
			height: 30px;
			line-height: 30px;
			padding: 0 10px;
			border-bottom: 1px solid #ddd;
		}

		.pinTuanJia li.active,.salesVolume b.active{
			color:{$_W['system_color']};
		}
		.pinTuanJia li text{
			margin-right:10px;
		}
		.pinTuanJia li img,.salesVolume b img{
			position: relative;
			right: -8px;
			width:70px;
			margin-right: 10px;
		}
</style>
<span id="numPerson">{$numPerson}</span>
<span id="numPrices">{$numPrices}</span>
<span id="numGroup">{$numGroup}</span>
<span id="goodsid">{$goods['id']}</span>

<div class="page-group">
    <div class="page page-current" id="page-goods-detail">
    	<div class="content">
    		<div class="dt_detail" >
			    <section class="detail_main" style="position:relative">
				<!--<div style="position:fixed;left:0px;top:0px;width:100%;height:100%;background-color:rgba(0,0,0,0.2);z-index:1;">
					<div></div>
				</div>-->
				{if  !empty($advs)}
			        <div class="sliderImage">
			            <div class="images" id="sliderImg" style="visibility: visible;">
			            	<ul>
			            		{loop $advs $adv}
			            		<li><img src="{php echo tomedia($adv['thumb']);}" style='width:100%;'></li>
			            		{/loop}
							</ul>
			            </div>
			            <div class="images_num" id="sliderNum">
			            	{php $slideNum = 1;}
					    	{loop $advs $adv}
					        <span{if $slideNum == 1} class="curr"{/if}></span>
					        {php $slideNum++;}
					    	{/loop}
			            </div>  
			        </div>
					{/if}
			    	<div class="productInfo" >
			    		<h2 style="padding-top: 10px;">{$goods['gname']}</h2>
			    		<span id="pricedown" {if $goods['isdownjia']==0}style="display:none;"{/if}>降价<br/>通知</span>
			    		<div class="editor">{$goods['goodsdesc']}</div>
			    	</div>
			    	<div class="salesVolume" style="display: block;"><span style="float: left;">{if $config['base']['ismarketprice']==0}市场价：￥{$goods['mprice']}{/if}</span>{if $config['base']['issell']==0}已售：{$goods['salenum']}/{$goods['unit']}{/if}</div>
					<!--<div style="padding-left:10px;color:#888;background-color:white;font-size:0.8em;">商品确认收货后可获得10086积分</div>-->
			    	
						
					<div class="progressOuter noShow"><span class="suc_tuan">已成团</span>
			    	<div class="progress"><div class="percent"></div></div><span class="total_tuan">共团</span></div>
			    	<div class="playTips" style="margin-top:-8px;">支付开团并邀请好友参加，达到人数拿最低价，差价组团成功或到期后自动退款，详见下方阶梯团玩法</div>
			    	<script>
					    $(function() {
					        new Swipe($('#sliderImg')[0], {
					            speed:500,
					            auto:3000,
					            callback: function(){
					                var lis = $("#sliderNum").children();
					                lis.removeClass("curr").eq(this.index).addClass("curr");
					            }
					        });
					    });
					</script>
			    </section>
			    <section class="goBuy" data-people="3" data-times="10" data_acttype="0" data_coupon="0" data_dealtype="" style="display: block;position:static">
			        <div class="btns" style="display: none;">
			            <div class="group_btn" id="buyGroup"><span class="price"><em>8.9元</em>/{$goods['unit']}</span><span class="colline"></span><span class="count">3人团&gt;</span></div>
			           <div class="single_btn" id="buySingle"><span class="price"><em>10.9元</em>/{$goods['unit']}</span><span class="colline"></span><span class="count">单独购买&gt;</span></div>
			        </div>
					
			        {if $goods['isshow']==3}
			        <div class="ico_end"></div>
			        {elseif $goods['isshow']==2}
			        <div class="ico_countdown"></div>
			        {/if}
			        <div class="tuan_btn" id="buyNow"><span>立即参团</span><span><i class="rowline"></i><em>8.9元</em>/{$goods['unit']}</span></div>
			        <div class="goIndexBtn">去首页逛逛吧</div>
			        <p class="activityTip"></p>
			    </section>
				<div class="pinTuanJia" data-num="{$nownum}">
					<div >拼团价</div>

					<div>
						<ul>
							{loop $param_level $item}
							<li  data-id="{$item['groupnum']}"><text>￥{$item['groupprice']}</text>{$item['groupnum']}人</li>
							{/loop}

						</ul>
					</div>
				</div>
			    <div class="space" style="display: none;"></div>
			    
			    <!--商家
				{if $merchant}
				<a href="{php echo $this->createMobileUrl('merchant',array('id'=>$merchant['id']));}">
	            <div class="mall_goods">
	                <img src="{php echo tomedia($merchant['thumb'])}">
	                <div class="mall_sub">
	                    <span>{$merchant['name']}</span>
	                    <div class="sales">销量：{$goods['salenum']}</div>
	                </div>
	                <div class="enter_button">
	                    <img src="http://pinduoduo.b0.upaiyun.com/mall/mall_icon_small.png">
	                    <span>进店逛逛</span>
	                </div>
	            </div>
	            </a>
	            {/if}-->
	            
	            <!--门店-->
				<!--
	            {if $goods['is_hexiao']==1}
				<div class="good_speci" onclick="showStores(this)" show="1">适用的商家信息<i class="fa fa-angle-down" style="float:right; line-height:44px; font-size:26px;"></i></div>
	  			<div>
		  			{loop $stores $stores}
			        <div class="store">
			            <div class="info">
			            <div class="ico"><i class="fa fa-university"></i></div>
			            <div class="info1">
			                <div class="inner">
			                     <div class="user">{$stores['storename']}</div>
			                     <div class="addresss">地址: {$stores['address']}</div>
			                     <div class="tel">电话: {$stores['tel']}</div>
			                 </div>
			             </div>
			             <a href="http://api.map.baidu.com/marker?location={$stores['lat']},{$stores['lng']}&amp;title={$stores['storename']}&amp;name={$stores['storename']}&amp;content={$stores['address']}&amp;output=html" class="external"><div class="ico2"><i class="fa fa-map-marker"></i></div></a>
			             <a href="tel:{$stores['tel']}" class="disable-router"><div class="ico3"><i class="fa fa-phone"></i></div></a>
			        	</div>
			        </div>
					{/loop}
		       	</div>
		       	{/if}
		       	-->
		       	<!--分享团-->
		       	{if !empty($thistuan)}
				{if ($share_data['share_type']==1 || $share_data['share_type']=='')}
					<div id="more_tuan" style="margin-top: 10px;{if $goods['ison']==0}display:none;{/if}">
					<div class="ht">
						<div class="ht_tit">附近的小伙伴正在发起团购，您可以直接参与</div>
						<div class="ht_list">
						{loop $thistuan $tuan}
						<div class="ht_item" style="height:160px;">
						<!--<span>{$tuan['nownum']}</span>-->
							<div class="ht_avatar"><img src="{$tuan['avatar']}" alt="团长头像"></div>
							<div class="ht_info"><div class="ht_name" style="float:none;">{$tuan['nickname']}</div><div class="ht_time" style="float:none;">发起时间：{php echo date('Y-m-d H:i:s', $tuan['starttime']);}</div></div>
							<!--<a href="{php echo app_url('order/group',array('tuan_id'=>$tuan['groupnumber']));}" class="ht_btn" ptag="20400.7.1"><span class="ht_price"><i>￥</i>{if !empty($tuan['price'])}{$tuan['price']}{else}{$goods['gprice']}{/if} / {$goods['unit']}</span><span class="ht_btn_go">差{$tuan['lacknum']}人成团，火速参团 》</span></a>-->
							<?php
									 $pernow=$tuan['nownum']/$tuan['neednum']*100;
									 $nowparam_level = unserialize($tuan['group_level']);
									
									if($nowparam_level){
										$num= round(((100-count($nowparam_level)*2)/count($nowparam_level)));
									}
									$goods['p'] = $nowparam_level[0]['groupprice'];
									foreach($nowparam_level as $item)
									{
										$numPerson.=",".$item['groupnum'];
										$numPrices.=",".$item['groupprice'];
									}
									$nownum=$tuan['neednum']-$tuan['lacknum'];
									for($i=0;$i<count($nowparam_level)-1;$i++){
			
										if($nowparam_level[$i]['groupnum']>$nownum&&$nowparam_level[$i+1]['groupnum']<=$nownum)
										{
											$tempprice=$nowparam_level[$i+1]['groupprice'];
											break;
										}
										if($nowparam_level[$i]['groupnum']==$nownum)
										{
											$tempprice=$nowparam_level[$i]['groupprice'];
											break;
										}
									}
									$nowprice=$tempprice;
									 ?>
							<div class="process" style="margin-top:20px;margin-bottom:20px;position:relative;width:100%;margin-left:5%;height:20px;border-radius:10px;background-color:white;border:1px solid hsl(354, 91%, 73%);margin-left:-25px;">
								<div class="progress" style="background-image:linear-gradient(90deg,#6fbfd8,hsl(354, 91%, 73%));height:100%;border-radius:10px;left:0px;top:0px;width:{$pernow}%">
									 {loop $nowparam_level $item}
									 <?php
									 $per=$item['groupnum']/$tuan['neednum']*100;
									 ?>
									<div class="progressStep" style="display:none;border:1px solid white;height:14px;width:4px;border-radius:7px;position:absolute;top:2px;background-color:white;left:{$per}%;">
										<div class="progressNum" style="position: absolute;top: -20px;width: 40px;text-align: center;left: -20px;line-height: 20px;height: 20px;">已有{$item['groupnum']}人参团</div>
										<div class="progressPrice" style="position: absolute;top: 14px;width: 40px;text-align: center;left: -20px;line-height: 20px;height: 20px;">{$item['groupprice']}</div>
									</div>
									{/loop}

									<div class="recentprogress" style="background-color:transparent;border:1px solid white;height:14px;width:100%;border-radius:7px;position:absolute;top:-15px;background-color:white;left:$pernow}%;">
										<div class="recentNum" style="color:red;position: absolute;top: -8px;width: 100%;text-align: right;line-height: 20px;height: 20px;">{$nownum}</div>
										<div class="recentPrice" style="display:none;color:red;position: absolute;top: 14px;width: 105px;text-align: right;left: -100px;line-height: 20px;height: 20px;">0.1</div>
									</div>
									<!--<div class="unitUp" style="position:absolute;right:-24px;top:-18px;">/人</div>-->
									<!--<div class="unitUp" style="position:absolute;right:-24px;top:16px;">/元</div>-->
									
								</div>
								
								<a href="{php echo app_url('order/orderconfirm',array('id' => $goods['id'],'tuan_id'=>$tuan['groupnumber'],'groupnum'=>$tuan['neednum']));}">
								<div style="height: 30px;line-height: 30px;text-align: center;width: 80%;background-color: rgb(248, 123, 136);border-radius: 20px;color: white;margin-left: 10%;margin-top:20px;">立即参团</div>
								</a>
							</div>
						</div>
						<script>
							/*var numPerson = document.getElementById("numPerson").textContent.slice(1).split(",");
							var numPrice  = document.getElementById("numPrices").textContent.slice(1).split(",");
							var progress = document.getElementsByClassName("progress");
							var recentNums = document.getElementsByClassName("recentNum");
							var recentPrices = document.getElementsByClassName("recentPrice");
							var Len = recentNums.length;
							var recentNum = Number(recentNums[Len - 1].textContent);
							var recentPrice = recentPrices[Len - 1];
							var priceLen = numPrice.length;
							var recentprogress = document.getElementsByClassName("recentprogress");
							for (var i = 0; i < priceLen; i++){
								if (recentNum < Number(numPerson[priceLen - 1])) {
									recentPrice.textContent = numPrice[priceLen - 1];			
									break;
								}
								
								else if (recentNum >= Number(numPerson[i+1]) && recentNum < Number(numPerson[i])) {
									recentPrice.textContent = numPrice[i+1];
									break;
								}
								
							}
							var percent = recentNum * 100 / Number(numPerson[0]) + "%";
							
							recentprogress[Len -1].style.left = percent;*/
						</script>
						{/loop}
						<!--<div id="jieTiGroup">
						
						</div>-->
						
						</div>
					</div>
					</div>
					{else}
					<div id="more_tuan" style="margin-bottom: 60px;">
						<div class="ht">
							<div style="text-align: center;">
							<a href="{php echo $this->createMobileUrl('goodsdetails',array('share_type'=>'share_type','id'=>$id));}" style="background-color: #FF5252;border-radius: 3px;width: 90%;height: 50px;text-align: center;color: rgb(255, 255, 255);margin-left: 5%;margin-top:5px;float: left;-webkit-border-radius: 3px;">
							<b><font size="5"><div class="ico2" style="margin-top: 10px;;"><i class="fa fa-map-marker"></i> 附近的团</div></font></b>
							</a>
							</div>
						</div>
					</div>
				{/if}
		        {/if}

			    <section class="stepGuild">
			        <div class="step_tit"><i></i>阶梯团玩法<span><span id="lookdetail">查看详情&gt;</span></span></div>
			        <div class="step_flow">
			            <div class="step_item step_item_on"><span class="step_num" >1</span><span>选择<br>心仪商品</span></div>
			            <div class="step_item"><span class="step_num">2</span><span class="steps">支付开团<br>或参团</span></div>
			            <div class="step_item"><span class="step_num">3</span><span class="steps">邀请好友<br>参团支付</span></div>
			            <div class="step_item"><span class="step_num">4</span><span class="steps">达到人数<br>拿最低价</span></div>
			        </div>
			    </section>
			</div>
			
			<div class="section_body info_detail" style="border:none">
				<div class="orderregion" style="border-bottom: none; margin-bottom: 10px;">
				    <h1 class="orderregion-title">
				        <i class="icon1-detail status-detail-icon"></i>
				        <label class="status-name">买家评价</label>
				        <a href="{php echo app_url('goods/judgment_list',array('op' => 'judgment_list','gid' => $id))}"><span style="float: right; color: #9d9d9d; font-size: 14px; height: 40px;line-height: 40px;  display: inline-block; ">共{$total}条记录&gt;</span></a>
				    </h1>
				
				        {loop $list $item}
				
						<div style="clear: both; padding:10px; padding-bottom:0px; text-align: justify; border-bottom: 1px solid #f0f0f0;">
							<div style="width: 12%; float: left;">
								<img style="max-height: 100%; max-width: 100%;" src="{$item['avatar']}" >
							</div>
							<div style="width: 80%; float:left;margin-left: 10px; ">
								<span style="color: #666;">{$item['openname']}</span><br>
								<span style="color: #666; font-size: 12px; ">{$item['time']}</span>
							</div>
							<div style="clear: both;"></div>
							<?php 
							$main_content = pdo_fetch("select * from ".tablename('tg_judgment_content')." where  judgment_id=:judgment_id order by update_time asc ",array('judgment_id'=>$item['judgment_id']));	
							$allcontent = pdo_fetchall("select * from ".tablename('tg_judgment_content')." where  judgment_id=:judgment_id and content_id <> '". $main_content['content_id'] ."'  order by update_time asc ",array('judgment_id'=>$item['judgment_id']));
							?>
							<div style="font-size: 0.9em; padding-top: 3px; padding-bottom: 3px; color: #1a1a1a;">{$main_content['content']}</div>
							{if !empty($allcontent)}
							<div><a style="color: gray" id="op{$main_content['judgment_id']}" onclick="$('#{$main_content['judgment_id']}').show();$('#op{$main_content['judgment_id']}').hide();">↓查看更多↓</a></div>
							<div id="{$main_content['judgment_id']}" style="display: none;">
								{loop $allcontent $content}
									{if $content['who']== 1}<span style="font-size: 0.75em;">[ 商家回复  ]</span>{/if}
									{if $content['who']== 0}<span style="font-size: 0.75em;">[ 用户追评  ]</span>{/if}<span style="margin-left:10px; color: #b8c0cc; font-size: 0.75em;"><?php echo date('Y-m-d H:i:s',$content['update_time']); ?></span>
									<div style="font-size: 0.9em; padding-top: 5px; padding-bottom: 5px;">{$content['content']}</div>
									
								{/loop}
							<div><a style="color: gray" id="op{$main_content['judgment_id']}" onclick="$('#{$main_content['judgment_id']}').hide();$('#op{$main_content['judgment_id']}').show();">↑不想看了↑</a></div>
							</div>
							{/if}
						
						</div>
						{/loop}
				    	
				</div>
			</div>
			
	        <div class="section_body info_detail" {if $goods['issharedesc']==1}style="display:none;"{/if}>
		        <div>
	            <div id="div_nav_fixed">
	                <div id="div_nav" class="div_nav">
	                    <ul class="boxx" style="padding-left: 0px;">
	                    	<li>
	                            <a onclick="exchange(1);" data-idx="1" class="sp on" id="shangpin1">图文详情</a>
	                        </li>
	                        <li>
	                            <a onclick="exchange(0);" data-idx="0" class="sp" id="shangpin0">商品属性</a>
	                        </li>
	                    </ul>
	                </div>
	            </div>
	            <div id="div_sections" class="div_sections">
	                <section class="section_specification">
	                	{loop $params $p}
	                    <dl>
	                        <div>
	                            <dd><label>{$p['title']}</label><label>{$p['value']}</label></dd>
	                        </div>
	                    </dl>
	                    {/loop}
	                </section>
	                <section class="section_detail on" data-role="widget" data-widget="img_prev_view">
	                    <div id="description" class="J_DetailSection tshop-psm tshop-psm-bdetaildes" style="margin:0px;padding:0px;">
	                        <div class="ke-post" id="productInfott" style="margin:10px 0px 0px;padding:0px;font-size:14px;font-family:tahoma, arial, 宋体, sans-serif;">
	                            
	                        </div>
	                    </div>
	                </section>


					
	            </div>
		        </div>
		    </div>
			<div>
			
			<h2 class="guesslike">猜你喜欢 ❤</h2>
<ul class="aboutProduct"></ul><!--aboutProduct-->
<script type="text/javascript">guesslike("{php echo app_url('goods/ajaxlist/goods_rand')}");</script>
			</div>
			
			<div style="height:65px;"></div>
			<input type="hidden" name="times" id="times" value="{$times}" />
		 	<input type="hidden" name="one_limit" id="one_limit" value="{$goods['one_limit']}" />
		 	<input type="hidden" name="many_limit" id="many_limit" value="{$goods['many_limit']}" />
	 	
			
    	</div>
	    
	    	 <style>
	   .group{position:relative;overflow:hidden;}
	   .group .qkt{width:1.2rem;height:100%;border-left:1px dashed #fff;position:absolute;top:0px;right:0px;color:#fff;line-height:1.1;text-align:center;padding-top:2px;}
	   </style>
	   
		<footer class="footer" style="z-index: 1!important;height: 50px;">
			
	        <nav>
	            <ul>					
	                <li style="width: 20%;"><a href="{php echo app_url('goods/list')}" id="gohome" class="nav-controller external"><img src="{TG_URL_ARES}images/icon_home.png" height="18px" width="19px"><br>首页</a></li>
					{if $goods['isshow']==1&&$goods['gnum']!=0}
					{if $goods['group_level_status']==2}
						<li class="group" style="color:white;"><a href="{php echo app_url('order/orderconfirm',array('groupnum'=>$numGroup,'id'=>$goods['id']));}" class="nav-controller"><i >￥{$goods['gprice']}</i>{$goods['groupnum']}人阶梯团</a><span class="qkt">去开团</span> </li>
						<li class="alone" style="color:white;"><a  style="color:white;" href="{php echo app_url('order/orderconfirm',array('groupnum'=>1,'id'=>$goods['id']));}" class="nav-controller external"><i >￥{$goods['oprice']}</i>单独购买</a></li>
	                	
					
					{/if}
					{else}
					<li class="group" style="width: 80%;"><a href="{php echo app_url('goods/list')}" style="line-height: 40px;font-size: 16px;" class="nav-controller external">查看更多拼团商品</a></li>
					{/if}
	            </ul>
	        </nav>
	    </footer>
	    <input type="hidden" id="buytype" value="" />
	    <input type="hidden" id="buytype2" value="{$goods['groupnum']}" />
	    <input type="hidden" id="optionid" name="optionid" value=""/>
	</div>
</div>


<div class="link-rule" style="display:none;">
	<div>
		<div>阶梯团须知</div> 		
		<div>			
			<div style="color:{$_W['system_color']};">什么是阶梯团？</div>	
			<p>每个商品都有单独购买价和阶梯拼团价，当您通过拼团价购买时，开团支付成功后再邀请朋友参团，参团人数达到组团规定时，系统将阶梯差价应退款金额自动退款至您的微信钱包中，然后在家坐等包裹。在规定时间内，若人数不足整团规定人数，在活动时间截止时，系统自动识别当前阶梯价格将阶梯差价应退款金额自动退款至您的微信钱包中，然后在家坐等包裹。</p >	
			<div style="color:{$_W['system_color']};">如何拼团成功，并取得最低阶梯价？</div>	
			<p>阶梯团是基于好友的转发扩散，获取团购优惠，达到规定人数自动降价退款至微信钱包。首先选择商品开团：选择拼团商品下单，团即刻开启，但团长完成支付，方能获取转发链接，并在团开启规定时间内邀请到相应人数的好友支付，此团方能成功获得本次阶梯团最低价。</p >		
			<div style="color:{$_W['system_color']};">团长干嘛的？</div>		
			<p>首先选择心仪的商品下单，并完成支付后即为团长。团长视为本次交易的发起人，且为第一位支付成功的成员。</p >	
			<div style="color:{$_W['system_color']};">拼团成员是什么？</div>		
			<p>通过分享出去的该团入口进入或者通过分享团入口进入并完成付款加入该团的团员，参团成员也可以将该团分享出去邀约更多的团员参团。</p >
		</div>
		<div id="link-know">已了解</div>
	</div>
</div>

<script>

	var User = JSON.parse(localStorage.getItem("user"))|| {};
	var goodsid = document.getElementById("goodsid");
	var pricedown = document.getElementById("pricedown");
	var urlNotice = "{php echo app_url('goods/list/notice')}";
	var urlNoticeRemove = "{php echo app_url('goods/list/noticeremove')}";
	if (User[goodsid.innerHTML + "notice"]) {
		pricedown.style.backgroundColor = "#fcc602";
		pricedown.innerHTML = "等待<br/>通知";
	}	
	pricedown.onclick = function() {
		if (pricedown.style.backgroundColor != "rgb(252, 198, 2)" && confirm("确认降价提醒么")) {
			postAjax(goodsid.innerHTML, urlNotice);
			pricedown.style.backgroundColor = "#fcc602";
			pricedown.innerHTML = "等待<br/>通知";
			User[goodsid.innerHTML + "notice"] = '1';
			localStorage.setItem("user",JSON.stringify(User));
		}
		else if (pricedown.style.backgroundColor == "rgb(252, 198, 2)" && confirm("确认取消降价提醒么")) {
			postAjax(goodsid.innerHTML, urlNoticeRemove);
			pricedown.style.backgroundColor = "#6fbfd8";
			pricedown.innerHTML = "降价<br/>通知";
			delete User[goodsid.innerHTML + "notice"];
			localStorage.setItem("user",JSON.stringify(User));
		}
	}
	function postAjax(id, url, weight, str){
		var formData = new FormData();
		formData.append('id', id);
		if (weight !== undefined) {
			formData.append("weight", weight);
		}else {
			formData.append("type", 2);
		}					
		if (str !==undefined){
		  formData.append("str",str);
		}
		var xhr = new XMLHttpRequest();
		xhr.open('post', url, true);
		xhr.send(formData);
		console.log(id + ' ' + weight + ' ' + str);
		xhr.onreadystatechange = function() {
			if (xhr.readyState ==4) {
			  if ((xhr.status >=200 && xhr.status<300) || xhr.status ==304){
				isPost = true;
				console.log(xhr.responseText);
				 return !!xhr.responseText;
			  }
			  else {
			    alert("由于网络或其他原因导致无法购买,请关闭浏览器重试");
				console.log("cuowu");
			  }
			}
		}
	}
	var gohome = document.getElementById("gohome");
	gohome.onclick = function() {
	  sessionStorage.removeItem("position");
	}
	document.getElementById("productInfott").innerHTML=escapeHtml('{$goods['gdesc']}');
	document.getElementById("link-know").onclick=function(){
		document.querySelector('.link-rule').style.setProperty("display","none");
	}
	document.getElementById("lookdetail").onclick=function(){
		document.querySelector('.link-rule').style.setProperty("display","block");
	}
	function bb(b, type, num){
	    if (b != 1 && !document.getElementById("popJieT") && !!window.Jtt){
			Jtt().init();
		}
		else if (b != 1 && !!window.Jtt && document.getElementById("popJieT").style.display == "none" && type == undefined){
			var popJieT = document.getElementById("popJieT");
			popJieT.style.display = "block";			
		}
		else if (b != 1 && !!window.Jtt && document.getElementById("popJieT").style.display == "block" && type == undefined){
			var popJieT = document.getElementById("popJieT");
			popJieT.style.display = "none";	
		}
		else {
			var many_limit = $("#many_limit").val();
			var one_limit = $("#one_limit").val();
			var times = $("#times").val();
			many_limit = parseInt(many_limit);
			one_limit=parseInt(one_limit);
			times=parseInt(times);
			
			if(b==1){
				location.href = "{php echo app_url('order/orderconfirm',array('groupnum'=>1));}";
			}
			else{
				if(many_limit>=1){
						if(times >= many_limit){
							$.toast('单人购买总数为：'+many_limit+',您已购买'+times);
							return false;
						}
					}
				var nn = Number(num) || "{$goods['groupnum']}";
				location.href = "{php echo app_url('order/orderconfirm')}" + "&groupnum=" + nn;
			}
			if (!!window.Jtt) {
				var popJieT = document.getElementById("popJieT");
				popJieT.style.setProperty("display", "none");
			}		
		}
	}
	
    $("#num").blur(function(){
		var inputnum=$("#num").val();
		var marketprice = 0;
	    var productprice = 0;
		var options = {php echo json_encode($options)};
		
		var ret = option_selected();
	    var len = options.length;
	        for (var i = 0; i < len; i++) {
	            var o = options[i];
	            var ids = ret.all.join("_");
	            if (o.specs == ids) {
	                optionid = o.id;
	                stock = o.stock;
	                marketprice = o.marketprice;
	                productprice = o.productprice;
	                break;
	            }
	        }
	    if(marketprice==0){
	     	marketprice = "{php echo $goods['gprice']}";
	    }
		var goodsPrice=marketprice;
		var totalPrice = goodsPrice*inputnum;
		totalPrice = totalPrice.toFixed(2);
		$("#option_gprice").html(totalPrice);
	});
	
	$("#up").bind('click',function(){
		var num = $('#num').val();
			num = parseInt(num)+1;
			$('#num').val(num);
		var marketprice = 0;
	    var productprice = 0;
		var options = {php echo json_encode($options)};
		var ret = option_selected();
	    var len = options.length;
	        for (var i = 0; i < len; i++) {
	            var o = options[i];
	            var ids = ret.all.join("_");
	            if (o.specs == ids) {
	                optionid = o.id;
	                stock = o.stock;
	                marketprice = o.marketprice;
	                productprice = o.productprice;
	                break;
	            }
	        }
	     if(marketprice==0){
	     	marketprice = "{php echo $goods['gprice']}";
	     }
		 if(productprice==0){
	     	productprice = "{php echo $goods['oprice']}";
	     }
		var goodsPrice=marketprice;
		var inputnum=num;
		var totalPrice = goodsPrice*inputnum;
		totalPrice = totalPrice.toFixed(2);
		$("#option_gprice").html(totalPrice);
		$("#option_oprice").html((productprice*inputnum).toFixed(2));
	});
	
	$("#down").bind('click',function(){
		var num = $('#num').val();
		num = parseInt(num)-1;
		if(num<=0){
			num=1;
		}
		$('#num').val(num);
		var marketprice = 0;
	    var productprice = 0;
		var options = {php echo json_encode($options)};
		var ret = option_selected();
	    var len = options.length;
	        for (var i = 0; i < len; i++) {
	            var o = options[i];
	            var ids = ret.all.join("_");
	            if (o.specs == ids) {
	                optionid = o.id;
	                stock = o.stock;
	                marketprice = o.marketprice;
	                productprice = o.productprice;
	                break;
	            }
	        }
	     if(marketprice==0){
	     	marketprice = "{php echo $goods['gprice']}";
	     }
		  if(productprice==0){
	     	productprice = "{php echo $goods['oprice']}";
	     }
		var goodsPrice=marketprice;
		var inputnum=num;
		var totalPrice = goodsPrice*inputnum;
		totalPrice = totalPrice.toFixed(2);
		$("#option_gprice").html(totalPrice);
		$("#option_oprice").html((productprice*inputnum).toFixed(2));
	});

   $("#num2").blur(function(){
	var inputnum=$("#num2").val();
	var gp=$("#gn").val();
		gp = inputnum * gp;
		$("#option_price").html(gp);
	});
	
	$("#up2").bind('click',function(){
		var num = $('#num2').val();
			num = parseInt(num)+1;
			$('#num2').val(num);
		var gp=$("#gn").val();
			gp = num * gp;
			$("#option_price").html(gp);
	});
	
	$("#down2").bind('click',function(){
		var num = $('#num2').val();
		num = parseInt(num)-1;
		if(num<=0){
			num=1;
		}
		$('#num2').val(num);
		var gp=$("#gn").val();
			gp = num * gp;
			$("#option_price").html(gp);
	});

    var options = {php echo json_encode($options)};
    var specs = {php echo json_encode($specs)};
    var hasoption = {php echo $goods['hasoption'] == '1' ? 'true' : 'false'};
	
    var selected = [];
    function option_selected() {
        var ret = {
            no: "",
            all: []
        };
        if (!hasoption) {
            return ret;
        }
        $(".optionid").each(function () {
            ret.all.push($(this).val());
            if ($(this).val() == '') {
                ret.no = $(this).attr("title");
                return false;
            }
        })
        return ret;
    }
	
	function closechoose(){
		$('.footer').show();
        $('.good_choose_layer').fadeOut(100);
		$('.good_choose').fadeOut(100); 
    }

	function exchange(numb) {
		$('#div_nav .boxx .sp').removeClass('on');
		$('.section_specification').removeClass('on');
		$('.section_detail').removeClass('on');
		$('a#shangpin'+numb).addClass('on');
		if(numb==0) {
			$('.section_specification').addClass('on');
		}else{
			$('.section_detail').addClass('on');
		}
	}
	
	function showStores(obj){
        if($(obj).attr('show')=='1'){
            $(obj).next('div').slideUp(100);
            $(obj).removeAttr('show').find('i').removeClass('fa-angle-down').addClass('fa-angle-up');
        }else{
            $(obj).next('div').slideDown(100);
            $(obj).attr('show','1').find('i').removeClass('fa-angle-up').addClass('fa-angle-down');
        }
    }
	//多团
	function Jtt() {
		var jtHtml = '<div id="popJieT" style="display:block;"></div>';
		var numTuan = document.getElementById("numJieT").textContent.split(",");
		var prices = document.getElementById("priceJieT").textContent.split(",");
		var module = {};
		var overHandler, leaveHandler, clickHandler;
		
		overHandler = function(ev) {
			ev.target.style.color = "#444";			
		}
		leaveHandler = function(ev) {
			ev.target.style.color = 'white';
		}
		clickHandler = function(ev) {
			var type = ev.target.dataset.num;
			if (!!window.choose) {
				return choose(2, 1, type);
			}
			else {
				return bb(2, 1, type);
			}
		} 
		
		module.prices = prices;
		module.numTuan = numTuan;
		module.init = function() {
			document.body.insertAdjacentHTML("beforeend", jtHtml);
			var popJieT = document.getElementById("popJieT");
			for (var i = 0; i < this.prices.length; i++) {
				var div = document.createElement("div");
				div.className = "jieStep";
				div.innerHTML = '￥' + this.prices[i] + '元' + '<br/>' + this.numTuan[i] + "人以上" ; 
				div.dataset.num = this.numTuan[i];
				div.onmouseenter = overHandler;
				div.onmouseleave = leaveHandler;
				div.onclick = clickHandler;
				popJieT.appendChild(div);
			}
		}
		return module;
	}
	//阶梯团
	/*function JTT() {
		var numPerson = document.getElementById("numPerson").textContent.split(",");
		var numPrices = document.getElementById("numPrices").textContent.split(",");
		var numGroup = Number(document.getElementById("numGroup").textContent);
		var jtthtml = '<div>'
				    + '<div>'
				    + '<div>团长:666</div>'
					+ '<div>参团人数:' + numGroup + '人</div>'
					+ '</div>'
					+ '<div id="process">'
					+ '<div id="progressBar"></div>'					
					+ '</div>'
					+ '<div id="payToGroup">我要参团</div>'
					+ '</div>';	
		var clickPayHandler, overPayHandler, leavePayHandler;
		clickPayHandler = function () {
			alert("去支付");
		}

		var module = {};
		module.numPerson = numPerson;
		module.numPrices = numPrices;
		module.init = function() {
			var jieTiGroup = document.getElementById("jieTiGroup");
			//alert(jieTiGroup);
			jieTiGroup.insertAdjacentHTML('beforeend', jtthtml);
			var progressBar = document.getElementById("progressBar");
			progressBar.style.width = Math.round(numGroup *100 / (Number(this.numPerson[this.numPerson.length - 1]) * 1.1)) + "%";
			var process = document.getElementById("process");
			var payToGroup = document.getElementById("payToGroup");
			payToGroup.onclick = clickPayHandler;
			payToGroup.onmouseleave = leavePayHandler;
			payToGroup.onmouseenter = overPayHandler;
			var over = document.getElementById("over");
			for (var i = 0; i < this.numPerson.length; i++) {
				var div = document.createElement("div");
				div.className = "progressStep";
				div.style.right = Math.round(101 - Number(this.numPerson[i]) * 100 / (Number(this.numPerson[this.numPerson.length - 1]) * 1.1))  + "%";
				div.innerHTML = '<div>'+ this.numPerson[i] +'</div><div>'+ this.numPrices[i]+'</div>';
				process.appendChild(div);
			}
			return module;
		}
		
		//return module;
	}*/
	//JTT().init();
</script>
{php include wl_template('common/footer');}